package com.meizhao.admin.service;

import cn.hutool.db.Db;
import cn.hutool.db.Entity;
import com.meizhao.admin.exception.CommonException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.sql.SQLException;

@Service
public class DemoService {

    private Db db;

    @Autowired
    public DemoService(Db db){
        this.db = db;
    }

    @Transactional(rollbackFor = Exception.class)
    public void save() throws SQLException {

        db.insert(Entity.create("account").set("age",100));
        throw new CommonException();
    }
}
